package com.renhuikeji.pro.ala.views;


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by Administrator on 2017/10/24.
 */

public class SearchView extends View {

    private Paint whitePaint;
    private Paint bluePaint;
    // 宽高
    private int mWidth, mHeight;


    private final int blue_color = Color.rgb(32, 149, 242);
    private final int text_color = Color.rgb(176, 174, 174);
    private final int white_color = Color.rgb(255, 255, 255);
    public SearchView(Context context) {
        this(context,null);
    }

    public SearchView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public SearchView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        whitePaint=new Paint(Paint.ANTI_ALIAS_FLAG);
        whitePaint.setColor(white_color);
        bluePaint=new Paint(Paint.ANTI_ALIAS_FLAG);
        bluePaint.setColor(blue_color);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        mWidth = w;
        mHeight = h;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
//        canvas.translate(mWidth / 2, mHeight / 2);
        RectF rectF = new RectF(0,0,mWidth,mHeight);
        canvas.drawRoundRect(rectF,mHeight/2,mHeight/2,whitePaint);
        RectF rectF1 = new RectF(mWidth-mHeight,0,mWidth,mHeight);
        canvas.drawArc(rectF1,-90,180,true,bluePaint);
    }
}
